package com.example.javabasic.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author: cph
 * @date: 2021/10/26 11:56
 */
@Slf4j
@RestController
public class GracefulShutdownController {

    @GetMapping("/sleep")
    public String sleep(int timeout) throws InterruptedException {
        log.info("begin sleep: {}", timeout);
        for (int i = 0; i < timeout; i++) {
            TimeUnit.SECONDS.sleep(1);
            log.info("i======>{}", i);
        }
        log.info("end sleep: {}", timeout);
        return "sleep: " + timeout;
    }
}
